<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace addons\equip\user\controller;


/**
 * Description of Equip
 * 属性记录
 * @author zmh
 */
class AttributeRecord extends \web\user\controller\AddonUserBase {

    public function index() {
        return $this->fetch();
    }

    /**
     * 装备列表
     * @return array
     */
    public function loadList() {
        $keyword = $this->_get('keyword');
        $status = $this->_get('status');
        $startDate = $this->_get('startDate');
        $endDate = $this->_get("endDate");
        $filter = '';
        if ($startDate != null && $endDate != null)
            $filter .= ' and (a.create_time >= \'' . $startDate . ' 00:00:00\' and a.create_time <= \'' . $endDate . ' 23:59:59\')';
        elseif ($startDate != null)
            $filter .= ' and (a.create_time >= \'' . $startDate . ' 00:00:00\')';
        elseif ($endDate != null)
            $filter .= ' and (a.create_time <= \'' . $endDate . ' 23:59:59\')';
        if ($keyword != null)
            $filter .= ' and b.username like \'%' . $keyword . '%\'';
        if ($status != null)
            $filter .= ' and a.status = ' . $status . ' ';

        $memberContributionM = new \addons\member\model\memberContribution();
        $total = $memberContributionM->getContributionTotal($filter);
        $rows = $memberContributionM->getContributionList($this->getPageIndex(), $this->getPageSize(), $filter);
        return $this->toDataGrid($total, $rows);
    }
}
